#include "GameObject.h"
#include "Director.h"

GameObject::GameObject()
	:_textureName(""), _position(0,0,0), _center(0.5f,0.5f,0)
	,_imageSize(0,0,0), _drawPoint(0,0,0), _rotation(0,0,0), _scale(1,1,0)
{
	// Construct
}


GameObject::~GameObject(void)
{
}

void GameObject::draw()
{
	RECT drawArea = {_drawPoint.x, _drawPoint.y,
					_drawPoint.x+_imageSize.x, _drawPoint.y+_imageSize.y};
	SharedDirector()->GetD3D9()->Draw(_textureName, drawArea, _position, _center, _rotation, _scale);
}


void GameObject::initTexture(string n)
{
	Texture* t = SharedDirector()->GetTexture(n);

	if( t )
	{
		setTextureName(n);
		setImageSize(Vector3l(t->width, t->height, 0));
	}
}

Vector3l GameObject::getImageSize()
{
	Texture* t = SharedDirector()->GetTexture(_textureName);

	if( t )
		return Vector3l(t->width, t->height);
	return Vector3l(0,0);
}
